package com.ukao.steward.eventbus;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by ukaodev on 2017/5/25.
 */

public class ShoppEvent<T> {

    public T data;
    public Message msg;
    public String id;
    public static enum Message {
        ADD_COUNT,UPDATE_ADDRESS,FINISH,CHAGE_ADD_COUNT,STORE
    }

    public ShoppEvent() {

    }

    public ShoppEvent(Message msg, T data) {
        this.msg = msg;
        this.data = data;
    }

    public ShoppEvent(Message msg, T data, String  id) {
        this.msg = msg;
        this.data = data;
        this.id = id;
    }

    public ShoppEvent(Message msg) {
        this.msg = msg;
    }

    public Message getMessage() {
        return msg;
    }

    public <T> T getData() {
        if (data == null) {

        }
        return (T) data;
    }

    public static <T> void postHasData(Message msg, T data) {
        EventBus.getDefault().postSticky(new ShoppEvent(msg, data));
    }


    public static <T> void postNoData(Message msg) {
        EventBus.getDefault().post(new ShoppEvent(msg));
    }

}
